//
//  File.swift
//  BasicTools
//
//  Created by ikang on 2025/8/15.
//

import Foundation

// 是否为闰年
// 1. 能被 4 整除但不能被 100 整除
// 2. 能被 400 整除

public struct LeapYear {
    static public func isLeapYear(_ year: Int) -> Bool {
        guard year >= 0 else { return false }
            
        if year % 400 == 0 {
            return true
        }else if year % 100 == 0 {
            return false
        }else {
            return year % 4 == 0
        }
    }
}

extension BasicWrapper where Base == Int {
    public var isLeapYear: Bool { get { LeapYear.isLeapYear(self.base) } }
}

extension BasicWrapper where Base == String {
    public var isLeapYear: Bool { get { LeapYear.isLeapYear(self.base.bt.intValue) } }
}


